import { useEffect, useRef } from 'react'
import { useDispatch } from 'react-redux'
import useConfig from '@/components/Chat/config'
import './index.less'
function ChatContainer() {
	const dispath = useDispatch()
	const wrapper = useRef()
	// 用于更新store数据得回调
	const updateStore = (callback, value) => {
		dispath(callback(value))
	}
	const config = useConfig(updateStore)
	useEffect(() => {
		const bot = new window.ChatSDK({
			root: wrapper.current,
			...config
		})
		bot.run()
	}, [])
	return <div style={{ height: '100%' }} ref={wrapper}></div>
}
export default ChatContainer
